<div class="margin10"></div>
<div class="no-records" *ngIf="dataSource.data.length <= 0">
  No Jobs Found
</div>
<table mat-table [dataSource]="dataSource" matSort matSortActive="created" matSortDirection="desc" *ngIf="dataSource.data?.length > 0" class="mat-elevation-z8">

  <!--- Note that these columns can be defined in any order.
        The actual rendered columns are set as a property on the row definition" -->

  <!-- jobDefinitionName Column -->
  <ng-container matColumnDef="jobDefinitionName">
    <th mat-header-cell *matHeaderCellDef mat-sort-header> Job </th>
    <td mat-cell *matCellDef="let element"> {{element.jobDefinitionName}} </td>
  </ng-container>

  <!-- status Column -->
  <ng-container matColumnDef="status">
    <th mat-header-cell *matHeaderCellDef mat-sort-header> Status </th>
    <td mat-cell *matCellDef="let element"> <app-job-queue-status [status]="element.status"></app-job-queue-status> </td>
  </ng-container>

  <!-- Added Column -->
  <ng-container matColumnDef="created">
    <th mat-header-cell *matHeaderCellDef mat-sort-header> Added </th>
    <td mat-cell *matCellDef="let element"> {{element.created | date:'MMM d, y, H:mm'}} </td>
  </ng-container>

  <!-- Updated Column -->
  <ng-container matColumnDef="updated">
    <th mat-header-cell *matHeaderCellDef mat-sort-header> Updated </th>
    <td mat-cell *matCellDef="let element"> {{element.updated | date:'MMM d, y, H:mm'}} </td>
  </ng-container>

  <!-- Action Column -->
  <ng-container matColumnDef="actions">
    <th mat-header-cell *matHeaderCellDef> </th>
    <td mat-cell *matCellDef="let element" class="action-buttons">
        <button mat-icon-button routerLink="../../{{element.id}}"
          matTooltip="Info" appHelpElement="JobQueue" subSection="Detail">
          <mat-icon>info</mat-icon>
        </button>
        <button mat-icon-button routerLink="../../{{element.id}}/logs"
          matTooltip="View Logs" appHelpElement="JobQueue" subSection="Logs">
          <mat-icon>description</mat-icon>
        </button>
    </td>
  </ng-container>

  <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
  <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator [pageSizeOptions]="[10, 20, 30]" showFirstLastButtons *ngIf="dataSource.data?.length > 0 && usePaging"></mat-paginator>
